package com.shop.controller;

import com.shop.pojo.GoodsOrderInfo;
import com.shop.result.JsonResult;
import com.shop.service.GoodsOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
@RequestMapping("/goodsOrder")
public class GoodsOrderInfoController {

    @Autowired
    private GoodsOrderInfoService goodsOrderInfoService;

    @RequestMapping("queryUserOrderByCondition")
    @ResponseBody
    public JsonResult queryUserOrderByCondition(HttpServletRequest request, HttpServletResponse response)throws Exception{
        List<GoodsOrderInfo> goodsOrderInfos = goodsOrderInfoService.queryUserOrderByCondition(request,response);
        return new JsonResult(true,goodsOrderInfos);
    }

    @RequestMapping("addUserOrderInfo")
    @ResponseBody
    public JsonResult addUserOrderInfo(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult result = goodsOrderInfoService.addUserOrderInfo(request,response);
        return result;
    }

    @RequestMapping("updateUserOrderStatus")
    @ResponseBody
    public JsonResult updateUserOrderStatus(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult result = goodsOrderInfoService.updateUserOrderStatus(request,response);
        return result;
    }

    @RequestMapping("deleteUserOrderById")
    @ResponseBody
    public JsonResult deleteUserOrderById(HttpServletRequest request, HttpServletResponse response)throws Exception{
        JsonResult result = goodsOrderInfoService.deleteUserOrderById(request,response);
        return result;
    }
}
